package com.ludomancy.gamelib.entity;

import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;

import com.ludomancy.gamelib.WorldScreenProjection;

public class Entity
{
	public Point pos;
	public World parent;
	public boolean visible = true;
	protected int width;
	protected int height;
	public int z = 0;
	
	public Entity(Point pos)
	{
		this.pos = new Point(pos);
	}
	
	public Point getHotspot()
	{
		return new Point(pos.x + getWidth()/2, pos.y + getHeight()/2);
	}
	
	// returns true if must stop updating world
	public boolean update()
	{
		return false;
	}
	
	public boolean active()
	{
		return true;
	}
	
	public int getWidth()
	{
		return width;
	}
	
	public int getHeight()
	{
		return height;
	}
	
	public boolean isMovable()
	{
		return active();
	}
	
	public Rectangle area()
	{
		return new Rectangle(pos.x, pos.y, getWidth(), getHeight());
	}
	
	public void onAdittion()
	{
		
	}
	
	public void onRemoval()
	{
		
	}

	public void paint(Graphics g, WorldScreenProjection projector)
	{
		if(visible)
		{
			int screenX = projector.worldToScreenX(pos.x - getWidth()/2);
			int screenY = projector.worldToScreenY(pos.y - getHeight()/2);
			paint(g, screenX, screenY);
		}
	}
	
	public int[] getBitmask(int x, int y, int w, int h)
	{
		return null;
	}
	
	public void paint(Graphics g, int screenX, int screenY)
	{		
	}
	
	public Point screenSize(WorldScreenProjection projector)
	{
		return projector.worldToScreen(new Point(getWidth(), getHeight()));
	}

	public void onClick(Point point)
	{
	}

	public void onBeginDrag()
	{
	}

	public void onEndDrag()
	{
	}

	public void onDrag(Point newpos)
	{
	}

	public void onDropCollision(Entity other)
	{
	}
}
